<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:p="http://primefaces.org/ui">

<ui:composition template="/auth/templates/template.xhtml">
	<ui:define name="pageTitle">Incluir Novo Usuário</ui:define>
	<ui:define name="body">
		<f:view>

			<p:growl id="messages" showDetail="true" autoUpdate="true"
				closable="true" />

			<h:form id="form">
				<h:panelGrid cellspacing="10px" styleClass="center">
					<f:facet name="header">Incluir Novo Usuário</f:facet>

					<ui:include src="/auth/usuario/painelsenha.xhtml" />

					<h:panelGroup rendered="#{usuarioVSBean.validUser}">
						<h:outputText value="Dados do Usuário" styleClass="header3" />
						<h:panelGrid cellspacing="10px">
							<p:outputLabel for="txtNome" value="Nome" />
							<p:inputText id="txtNome" value="#{usuarioVSBean.nomeUsuario}"
								required="true" />
							<p:outputLabel for="txtApelido" value="Apelido" />
							<p:inputText id="txtApelido"
								value="#{usuarioVSBean.apelidoUsuario}" required="true" />
							<p:outputLabel for="txtSenha" value="Senha" />
							<p:inputText id="txtSenha" value="#{usuarioVSBean.senhaUsuario}"
								required="true" />
							<p:outputLabel for="txtPermissao" value="Nome Permissão" />
							<h:panelGroup>
								<p:inputText id="txtPermissao"
									value="#{usuarioVSBean.nomePermissao}" />
								<p:commandButton value="Incluir" icon="ui-icon-plus"
									update="@form"
									actionListener="#{usuarioVSBean.adicionaPermissao}"
									style="margin-left:10px;" />
							</h:panelGroup>
							<h:panelGroup>
								<p:orderList id="txtPermissoes"
									value="#{usuarioVSBean.permissoesUsuario}" var="permissao"
									controlsLocation="none" itemLabel="#{permissao}"
									itemValue="#{permissao}">
									<f:facet name="caption">Permissões</f:facet>
								</p:orderList>

							</h:panelGroup>
						</h:panelGrid>
						<p:commandButton value="Enviar" icon="ui-icon-check"
							update="@form" action="#{usuarioVSBean.incluirUsuario()}" />
					</h:panelGroup>
				</h:panelGrid>
			</h:form>
		</f:view>
	</ui:define>
</ui:composition>

</html>